#方法1
class Solution:
    def ReverseList(self , head: ListNode) -> ListNode:
        cur = head
        pre = None

        while cur:
            tmp = cur.next
            cur.next = pre
            pre = cur
            cur = tmp
        return pre
#方法2
class Solution:
    def ReverseList(self, head: ListNode) -> ListNode:
        if not head:
            return None
        if not head.next:
            return head

        l = head
        m = head.next
        r = head.next.next
        l.next = None

        while r:
            m.next = l
            l = m
            m = r
            r = r.next
        m.next = l
        return m